package com.cdtu.room.service.impl;

import java.util.List;

import com.cdtu.room.dto.EquipmentDto;
import com.cdtu.room.vo.EquipmentVo;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.cdtu.room.mapper.EquipmentMapper;
import com.cdtu.room.domain.Equipment;
import com.cdtu.room.service.IEquipmentService;

/**
 * 会议室设备Service业务层处理
 * 
 * @author hcc
 * @date 2024-02-27
 */
@Service
public class EquipmentServiceImpl implements IEquipmentService 
{
    @Autowired
    private EquipmentMapper equipmentMapper;

    /**
     * 查询会议室设备
     * 
     * @param equipmentId 会议室设备主键
     * @return 会议室设备
     */
    @Override
    public Equipment selectEquipmentByEquipmentId(Long equipmentId)
    {
        return equipmentMapper.selectEquipmentByEquipmentId(equipmentId);
    }

    /**
     * 新增会议室设备
     * 
     * @param equipment 会议室设备
     * @return 结果
     */
    @Override
    public int insertEquipment(Equipment equipment)
    {
        equipment.setStatus(1);
        equipment.setCreateBy(SecurityUtils.getUsername());
        equipment.setCreateTime(DateUtils.getNowDate());
        return equipmentMapper.insertEquipment(equipment);
    }

    /**
     * 修改会议室设备
     * 
     * @param equipment 会议室设备
     * @return 结果
     */
    @Override
    public int updateEquipment(Equipment equipment)
    {
        equipment.setUpdateBy(SecurityUtils.getUsername());
        equipment.setUpdateTime(DateUtils.getNowDate());
        return equipmentMapper.updateEquipment(equipment);
    }

    /**
     * 批量删除会议室设备
     * 
     * @param equipmentIds 需要删除的会议室设备主键
     * @return 结果
     */
    @Override
    public int deleteEquipmentByEquipmentIds(Long[] equipmentIds)
    {
        return equipmentMapper.deleteEquipmentByEquipmentIds(equipmentIds);
    }

    /**
     * 删除会议室设备信息
     * 
     * @param equipmentId 会议室设备主键
     * @return 结果
     */
    @Override
    public int deleteEquipmentByEquipmentId(Long equipmentId)
    {
        return equipmentMapper.deleteEquipmentByEquipmentId(equipmentId);
    }

    /**
     * 查询会议室设备列表
     * @param equipmentVo
     * @return
     */
    @Override
    public List<EquipmentDto> getEquipmentList(EquipmentVo equipmentVo) {
        return equipmentMapper.getEquipmentList(equipmentVo);
    }

    /**
     * 查询会议室设备列表
     * @param equipment
     * @return
     */
    @Override
    public List<Equipment> selectEquipmentList(Equipment equipment) {
        return equipmentMapper.selectEquipmentList(equipment);
    }

    /**
     * 校验会议室下是否有设备通过会议室ID
     * @param roomId
     * @return
     */
    @Override
    public List<Equipment> getEquipmentByRoomId(Long roomId) {
        return equipmentMapper.getEquipmentByRoomId(roomId);
    }
}
